class debug {
}

debug.debug_msg_list = [];
debug.debug_msg_max_count = 5;
debug.debug_widget = null;
debug.init_debug = function () {
    if (debug.debug_widget != null)
        return false;
    debug.debug_widget = document.createElement("p");
    document.body.insertBefore(debug.debug_widget, document.body.firstChild);
    debug.debug_widget.style = "white-space: pre; position: absolute; color: red; margin: 10px 10px; user-select: none;";
    return true;
}
debug.print = function (message) {
    if (debug.debug_msg_list.length > debug.debug_msg_max_count)
        debug.debug_msg_list.pop();
    debug.debug_msg_list.unshift(message);
    let content = "";
    for (let i = 0; i < debug.debug_msg_list.length; i++) {
        content += debug.debug_msg_list[debug.debug_msg_list.length - i - 1];
        content += "\n";
    }
    debug.debug_widget.textContent = content;
}